/**
 * 阅读tab相关接口
 */
import type { GameResult, GetSubmitAnwserParams, GetSubmitAnwserResult, HomeWorkResult, ListParams, QuestionResult } from './types';
import type { ReadingBookResult } from '@/api/home/type';
import { get, post } from '@/utils/request';

enum URL {
  getCourseList = '/userMainPage/getCourseList',
  getNowBookQuestions = '/userReadPage/getNowBookQuestions',
  getBookGame = '/userReadPage/getBookGame',
  getSubmitAnwser = '/userReadPage/getSubmitAnwser',
  getCheckGaming = '/userReadPage/getCheckGaming',
  uploadHomeWork = '/userReadPage/uploadHomeWork',
  getHomeWork = '/userReadPage/getHomeWork',
  getPreview = '/userReadPage/getPreview',
}

// 查看课表   和  阅读TAB 的 课程列表一样  带分页  适用于 “下拉更多”
export const getCourseList = (data: ListParams) => get<{ total: number; rows: Array<ReadingBookResult> }>({ url: URL.getCourseList, data });

// 获取打卡 试题--一次性加载所有的选择题。
export const getNowBookQuestions = (data: { cdId: string }) => get<{ total: number; questions: Array<QuestionResult> }>({ url: URL.getNowBookQuestions, data });

// 获取 某一课的游戏管卡
export const getBookGame = (data: { courseId: string }) => get<{ totalLevels: Array<GameResult> }>({ url: URL.getBookGame, data });

// 提交考题答案
export const getSubmitAnwser = (data: GetSubmitAnwserParams) => post<GetSubmitAnwserResult>({ url: URL.getSubmitAnwser, data });

// 判断这个管卡能不能玩
export const getCheckGaming = (data: { courseId: string; courseDetailId: string }) => get<any>({ url: URL.getCheckGaming, data });

// 上传作业图片
export const uploadHomeWork = (data: { id: string; assigPic: string }) => post<any>({ url: URL.uploadHomeWork, data });

// 打开上传作业
export const getHomeWork = (data: { courseId: string }) => get<HomeWorkResult>({ url: URL.getHomeWork, data });

// 记录用户点开过 课前预习按钮
export const getPreview = (data: { id: string }) => get<any>({ url: URL.getPreview, data });
